package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.entity.AfBrand;
import com.example.demo.mapper.AfBrandMapper;
import com.example.demo.service.IAfBrandService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mr.We
 * @since 2024-06-21
 */
@Service
public class AfBrandServiceImpl extends ServiceImpl<AfBrandMapper, AfBrand> implements IAfBrandService {
    @Resource
    private AfBrandMapper afBrandMapper;

    @Override
    public AfBrand queryObject(Integer id) {
        return afBrandMapper.queryObject(id);
    }

    @Override
    public List<AfBrand> queryList(Map<String, Object> map) {
        return afBrandMapper.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return afBrandMapper.queryTotal(map);
    }

    @Override
    public boolean save(AfBrand brand){
        if (brand != null){
            afBrandMapper.insert(brand);
            return true;
        }
        return false;
    }


    public void update(AfBrand brand){
        QueryWrapper<AfBrand> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", brand.getId());
        afBrandMapper.update(queryWrapper);
    }


    public void delete(Integer id){
        QueryWrapper<AfBrand> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", id);
        afBrandMapper.delete(queryWrapper);
    }


    public void deleteBatch(Integer[] ids){
        QueryWrapper<AfBrand> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("id", (Object) ids);
        afBrandMapper.delete(queryWrapper);
    }
}
